import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryGeneratedColumn
} from "typeorm";
import Decimal from "decimal.js";
import {v4 as uuidv4} from 'uuid'

@Entity()
export class User {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    comment: '用户名',
    unique: true,
  })
  username: string;

  @Column({
    comment: '密码',
  })
  password: string;

  @Column({
    comment: '用户状态 1 可用 2 封禁 3 删除',
    type: "int",
    default: 1
  })
  status: number;

  @CreateDateColumn({
    comment: '注册时间',
  })
  createTime: Date;

  @Column({
    comment: '用户生日',
    type: 'date',
    nullable: true,
    default: null,
  })
  birthday: Date | null;

  @Column({
    comment: '真实姓名',
    nullable: true,
    default: null
  })
  realName: string | null;

  @Column({
    comment: '手机号',
    unique: true,
    nullable: true,
    default: () => 'NULL'
  })
  phone: string;

  @Column({
    comment:"用户钱包",
    type: "decimal",
    scale: 2,
    default: 0.00,
    transformer: {
      from: (value) => new Decimal(value).toNumber(),
      to: (value) => value,
    }
  })
  money: number;

  @Column({
    comment: '用户唯一标识',
    unique: true
  })
  uniqueToken: string;
}
